﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OurWedding1
{
    public static class SessionExtensions
    {
        public static T GetDataFromSession<T>(this HttpSessionStateBase session, string key)
        {
            return (T)session[key];
        }

        public static void SetDataInSession<T>(this HttpSessionStateBase session, string key, object value)
        {
            session[key] = value;
        }

        public static Nullable<int> GetCurrentWeddingId(this HttpSessionStateBase session)
        {

            Nullable<int> result;
            if (session["_WeddingId"] != null)
            {
                result = (int)session["_WeddingId"];
            }
            else
            {
                result = null;
            }
            return result;
        }
    }
}